package com.bai.ad.util;

import java.util.Map;
import java.util.StringJoiner;
import java.util.function.Supplier;

/**
 * ClassName CommonUnits
 *
 * @author Bai
 * @version 1.0
 * @date 2019/2/26 0026 下午 22:57
 **/
public class CommonUtils {

    public static <K, V> V getorCreate(K key, Map<K, V> map,
                                       Supplier<V> factory){
        return map.computeIfAbsent(key, k -> factory.get());
    }

    public static String stringConcat(String... strings){
        StringJoiner stringJoiner = new StringJoiner("-");
        for (String string : strings){
            stringJoiner.add(string);
        }
        return stringJoiner.toString();
    }
}
